import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:village_android/model/menu_model.dart';
import 'package:village_android/pages/article/article_list.dart';

class HomeTitleButton extends StatelessWidget {
  final String text;
  int module;
  int type;
  final Color color;
  final Object callBack;

  HomeTitleButton(
      {Key key,
      this.color = Colors.white70,
      this.text = '按钮',
      this.module,
      this.type,
      this.callBack})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
        height: 35,
        alignment: Alignment.center,
        padding: EdgeInsets.all(5.0),
        color: Colors.white30,
        child: new Stack(children: <Widget>[
          new Align(
            alignment: new FractionalOffset(0.0, 0.0),
            child: Container(
              padding: EdgeInsets.only(left: 20.0),
              child: SizedBox(
                height: 25,
                width: double.infinity,
                child: Text(
                  this.text,
                  textAlign: TextAlign.left,
                  style: TextStyle(color: Colors.red, fontSize: 17),
                ),
              ),
            ),
          ),
          new Align(
            alignment: FractionalOffset.topRight,
            child: InkWell(
              onTap: () {
                pushToList(context);
              },
              child: Container(
                width: 60,
                height: 35,
                child: Center(
                  child: Icon(
                    Icons.more_horiz,
                    color: Colors.black,
                    size: 30.0,
                  ),
                ),
              ),
            ),
          ),
        ]));
  }

  void pushToList(BuildContext context) {
    MenuModel menuModel = MenuModel(this.text, this.type, this.module, null);
    var page = new ArticleListPage(
      menuModel: menuModel,
    );
    Navigator.push(context, new MaterialPageRoute(builder: (context) => page));
  }
}
